package spring6_learn.service;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class test {

    public static void main(String[] args) {
        userService target = new userServiceImpl();
        //三个参数
        //target.getClass().getClassLoader()获取目标类的类加载器
        //target.getClass().getInterfaces(),获取目标类实现的接口
        //new TimeInvocationHandler( target)    调用处理器，也就是增强的代码
        userService proxyInstance = (userService) Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), new TimeInvocationHandler( target));
        proxyInstance.inint();
        proxyInstance.save();
        proxyInstance.destroy();
        System.out.println(proxyInstance.getName());

    }
}
